import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

export const constantRouterMap = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard'),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'el-icon-s-home', noCache: true }
      }
    ]
  }
]

// 职工目录
export const employees = [
  {
    path: '/information',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/views/employee/information'),
        name: 'information',
        meta: { title: '个人信息', icon: 'el-icon-s-help', noCache: true }
      }
    ]
  }, {
    path: '/attendance',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/views/employee/attendance'),
        name: 'attendance',
        meta: { title: '个人考勤', icon: 'el-icon-s-ticket', noCache: true }
      }
    ]
  }, {
    path: '/ask_for_leave',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/views/employee/ask_for_leave'),
        name: 'ask_for_leave',
        meta: { title: '我的请假', icon: 'el-icon-s-check', noCache: true }
      }
    ]
  }, {
    path: '/file',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/views/employee/file'),
        name: 'file',
        meta: { title: '我的文件', icon: 'el-icon-files', noCache: true }
      }
    ]
  }
]

// 管理员目录
export const administrators = [
  {
    path: '/employee_manage',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/views/administrator/employee_manage'),
        name: 'employee_manage',
        meta: { title: '员工信息管理', icon: 'el-icon-user-solid', noCache: true }
      }
    ]
  },
  {
    path: '/attendance_manage',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/views/administrator/attendance_manage'),
        name: 'attendance_manage',
        meta: { title: '考勤管理', icon: 'el-icon-s-data', noCache: true }
      }
    ]
  }, {
    path: '/project',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/views/administrator/project'),
        name: 'project',
        meta: { title: '项目管理', icon: 'el-icon-s-cooperation', noCache: true }
      }
    ]
  }, {
    path: '/dept',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/views/administrator/dept'),
        name: 'dept',
        meta: { title: '部门管理', icon: 'el-icon-share', noCache: true }
      }
    ]
  }, {
    path: '/file_manage',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/views/administrator/file_manage'),
        name: 'file_manage',
        meta: { title: '文件管理', icon: 'el-icon-files', noCache: true }
      }
    ]
  }, {
    path: '/ask_for_leave_manage',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/views/administrator/ask_for_leave_manage'),
        name: 'ask_for_leave_manage',
        meta: { title: '请假管理', icon: 'el-icon-message-solid', noCache: true }
      }
    ]
  }
]

export default new Router({
  // mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  // ...employees,
  // ...administrators,
  { path: '*', redirect: '/404', hidden: true }
]
